<template>
	<view class="bg-white">
		<cu-custom :isBack="true">
			<block #content>
				操作日志详细
			</block>
		</cu-custom>
		
		<view class="bg-white margin padding">
			<view class="">
				<text class="margin-right-sm text-bold text-black">操作模块:</text>
				<text class="text-sm">{{title}}</text>
			</view>
			<view class="margin-top">
				<text class="margin-right-sm text-bold text-black">登录信息:</text>
				<text class="text-sm">{{ operName }} / {{ operIp }} / {{ operLocation }}</text>
			</view>
			<view class="margin-top">
				<text class="margin-right-sm text-bold text-black">请求地址:</text>
				<text class="text-sm">{{operUrl}}</text>
			</view>
			<view class="margin-top">
				<text class="margin-right-sm text-bold text-black">请求方式:</text>
				<text class="text-sm">{{requestMethod}}</text>
			</view>
			<view class="margin-top">
				<text class="margin-right-sm text-bold text-black">操作方法:</text>
				<text class="text-sm">{{method}}</text>
			</view>
			<view class="margin-top">
				<text class="margin-right-sm text-bold text-black">请求参数:</text>
				<text class="text-sm">{{operParam}}</text>
			</view>
			<view class="margin-top">
				<text class="margin-right-sm text-bold text-black">返回参数:</text>
				<text class="text-sm">{{jsonResult}}</text>
			</view>
			<view class="margin-top">
				<text class="margin-right-sm text-bold text-black">操作状态:</text>
				<text class="text-sm">{{statusValue}}</text>
			</view>
			<view class="margin-top">
				<text class="margin-right-sm text-bold text-black">操作时间:</text>
				<text class="text-sm">{{operTime}}</text>
			</view>
			<view v-if="status === 1" class="margin-top">
				<text class="margin-right-sm text-bold text-black">异常信息：:</text>
				<text class="text-sm">{{errorMsg}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		showToast,
		showLoading,
		hideLoading
	} from '@/util/toast'
	import {
		formatDateTime,
		formatDate
	} from '@/util/formatTime'
	import * as monitorApi from '@/api/dmIot/monitorApi.ts'
	
	export default {
		data() {
			return {
				title:"",
				operName:"",
				operIp:"",
				operLocation:"",
				operUrl:"",
				requestMethod:"",
				method:"",
				operParam:"",
				jsonResult:"",
				operTime:"",
				errorMsg:"",
				status:0,
				statusValue:""
			}
		},
		computed: {
			themeConfig() {
				return this.$store.state.themeConfig
			}
		},
		onLoad(e) {
			this.getOperlog(e.operId)
		},
		methods: {
			formatDate(time) {
				return formatDate(time, this.$t('unKnow'))
			},
			formatDateTime(time) {
				return formatDateTime(time, this.$t('unKnow'))
			},
			getOperlog(operId){
				monitorApi.getOperlog(operId).then((res) => {
					const {
						data,
						success
					} = res
					if (success) {
						let {title,operName,operIp,operLocation,operUrl,requestMethod,method,operParam,jsonResult,operTime,errorMsg,status,statusValue} = data
						this.title = title
						this.operName = operName
						this.operIp = operIp
						this.operLocation = operLocation
						this.operUrl = operUrl
						this.requestMethod = requestMethod
						this.method = method
						this.operParam = operParam
						this.jsonResult = jsonResult
						this.operTime = operTime
						this.errorMsg = errorMsg
						this.status = status
						this.statusValue = statusValue
					}
				})
			}
		},
		onShareAppMessage(res) {
			return {
				title: `中泰能`,
				path: `/pages/login/login`,
				success: (res) => {
					// console.log(res)
				}
			}
		}
	}
</script>

<style>
</style>